public class Solution4 {
    public ListNode reverseList(ListNode head) {
        if(head==null)
            return head;
        if(head.next==null)
            return head;

        ListNode n1 = head;
        ListNode n2 = null;
        ListNode n3 = head.next;

        while(n2!=null){
            n1.next=n2;
            n2=n1;
            n1=n3;
            if(n3!=null)
                n3=n3.next;
        }
        return n2;
    }
}